#include "widget.h"
#include "ui_widget.h"
#include <QIcon>
#include <QCursor>
#include <QDebug>
#include <QRect>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowTitle(QString("hello world"));
    this->setWindowIcon(QIcon(":/snorlax.png"));
    QPixmap pic(":/redlip.png");
    pic = pic.scaled(60, 60);
    this->setCursor(QCursor(pic, 20, 20));
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_add_clicked()
{
    double opacity = this->windowOpacity();
    qDebug() << opacity;
    if (opacity >= 1.0)
        return;
    opacity += 0.1;
    this->setWindowOpacity(opacity);
}

void Widget::on_pushButton_sub_clicked()
{
    double opacity = this->windowOpacity();
    qDebug() << opacity;
    if (opacity <= 0.1)
        return;
    opacity -= 0.1;
    this->setWindowOpacity(opacity);
}

void Widget::on_pushButton_up_clicked()
{
    QRect rect = ui->pushButton->geometry();
    ui->pushButton->setGeometry(rect.x(), rect.y() - 5, rect.width(), rect.height());
}

void Widget::on_pushButton_down_clicked()
{
    QRect rect = ui->pushButton->geometry();
    ui->pushButton->setGeometry(rect.x(), rect.y() + 5, rect.width(), rect.height());
}

void Widget::on_pushButton_left_clicked()
{
    QRect rect = ui->pushButton->geometry();
    ui->pushButton->setGeometry(rect.x() - 5, rect.y(), rect.width(), rect.height());
}

void Widget::on_pushButton_right_clicked()
{
    QRect rect = ui->pushButton->geometry();
    ui->pushButton->setGeometry(rect.x() + 5, rect.y(), rect.width(), rect.height());
}
